package data;

import java.util.ArrayList;

public class User {
    private String id;
    private String username;
    private String password;
    private String level;
    private int registerTime;
    private double totalAmount;
    private String phoneNumber;
    private String email;
    public User(){
    }
    // 带参数的构造函数，用于创建用户对象时初始化所有属性
    public User(String id, String username,  String level, int registerTime, double totalAmount, String phoneNumber, String email) {
        this.id = id;
        this.username = username;
        this.level = level;
        this.registerTime = registerTime;
        this.totalAmount = totalAmount;
        this.phoneNumber = phoneNumber;
        this.email = email;
    }
    // 用于创建用户对象时初始化用户名、密码、电话号码和电子邮件地址
    public User(String username, String password, String phonenumber, String email) {

        this.username=username;
        this.password=password;
        this.phoneNumber=phonenumber;
        this.email=email;

    }
    // 检查ArrayList中是否存在具有给定用户名的用户
    public static boolean contains(ArrayList<User> list, String username){
        for (User user : list) {
            String rightUsername = user.getUsername();
            if (rightUsername.equals(username)) {
                return true;
            }
        }
        return false;
    }
    // 获取用户ID的方法
    public String getid(){
        return id;
    }
    // 获取用户等级的方法
    public String getLeval(){
        return level;
    }
    // 获取注册时间的方法
    public int getRegisterTime(){
        return registerTime;
    }
    // 获取消费总额的方法
    public double getTotalAmount() {
        return totalAmount;
    }
    // 获取电话号码的方法
    public String getPhoneNumber() {
        return phoneNumber;
    }
    // 获取用户名的方法
    public String getUsername(){
        return username;
    }
    // 设置密码的方法
    public void setPassword(String password){
        this.password=password;
    }
    // 获取电子邮件地址的方法
    public String getEmail() {
        return email;
    }
    // 获取密码的方法
    public String getPassword(){
       return password;
    }
}